//将数组前一半的值和后一半的值对换

#include <stdio.h>
int main()
{
        int a[81];
        int n,i,j,temp;
        printf("input a number: ");
        scanf("%d",&n);
        printf("输入数组各个数字:");
        for (i=0;i<n;i++)
                scanf("%d",&a[i]);
        for (i=0;i<n/2;i++)
        {
                temp=a[i];
                a[i]=a[i+n/2+n%2];       //用加上n%2，来控制奇数个数据时
                a[i+n/2+n%2]=temp;       //程序正常运行
        }
        for (i=0;i<n;i++)
                printf("%d ",a[i]);
        printf("\n");

        return 0 ;
}

